<!doctype html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title><・)))><<</title>
    <link rel="shortcut icon" href="favicon.ico">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=Edge">
    <meta name="viewport"
          content="width=device-width,initial-scale=1.0,user-scalable=no,minimum-scale=1,maximum-scale=1">
    <meta HTTP-EQUIV="pragma" content="no-cache">
    <meta HTTP-EQUIV="Cache-Control" content="no-cache, must-revalidate">
    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no">
    <meta HTTP-EQUIV="expires" content="0">
    <meta name="viewport"
          content="width=device-width,initial-scale=1,minimum-scale=1, maximum-scale=1, user-scalable=no, viewport-fit=cover"/>
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link href="https://fonts.googleapis.com/css2?family=Poppins:wght@600;900&display=swap" rel="stylesheet">
    <style>
        body, html {
            background-color: #000;
            color: #fff;
            width: 100%;
            height: 100%;
            margin: 0;
            padding: 0;
            overflow: hidden;
        }

        canvas {
            position: absolute;
            top: 0;
            left: 0
        }
    </style>
</head>
<body>

<canvas id="bgCanvas"></canvas>

<script>
    (function () {
        var requestAnimationFrame = window.requestAnimationFrame || window.mozRequestAnimationFrame || window.webkitRequestAnimationFrame || window.msRequestAnimationFrame || function (callback) {
            window.setTimeout(callback, 1000 / 60);
        };
        window.requestAnimationFrame = requestAnimationFrame;
    })();

    // Terrain stuff.
    var background = document.getElementById("bgCanvas"),
        bgCtx = background.getContext("2d"),
        width = window.innerWidth,
        height = document.body.offsetHeight;

    (height < 400) ? height = 400 : height;

    background.width = width;
    background.height = height;

    //判断是否为手机访问
    function isMobile() {
        var userAgentInfo = navigator.userAgent;
        var mobileAgents = ["Android", "iPhone", "SymbianOS", "iPad", "iPod", "ipad", "android", "iphone", "ipod"];//Windows Phone
        var mobile_flag = false;
        //根据userAgent判断是否是手机
        for (var v = 0; v < mobileAgents.length; v++) {
            if (userAgentInfo.indexOf(mobileAgents[v]) > 0) {
                mobile_flag = true;
                break;
            }
        }
        return mobile_flag;
    }

    function Terrain(options) {
        options = options || {};
        this.terrain = document.createElement("canvas");
        this.terCtx = this.terrain.getContext("2d");
        this.scrollDelay = options.scrollDelay || 90;
        this.lastScroll = new Date().getTime();

        this.terrain.width = width;
        this.terrain.height = height;
        this.fillStyle = options.fillStyle || "#191D4C";
        this.mHeight = options.mHeight || height;

        // generate
        this.points = [];

        var displacement = options.displacement || 140,
            power = Math.pow(2, Math.ceil(Math.log(width) / (Math.log(2))));

        // set the start height and end height for the terrain
        this.points[0] = this.mHeight;//(this.mHeight - (Math.random() * this.mHeight / 2)) - displacement;
        this.points[power] = this.points[0];

        // create the rest of the points
        for (var i = 1; i < power; i *= 2) {
            for (var j = (power / i) / 2; j < power; j += power / i) {
                this.points[j] = ((this.points[j - (power / i) / 2] + this.points[j + (power / i) / 2]) / 2) + Math.floor(Math.random() * -displacement + displacement);
            }
            displacement *= 0.6;
        }

        document.body.appendChild(this.terrain);
    }

    Terrain.prototype.update = function () {
        // draw the terrain
        this.terCtx.clearRect(0, 0, width, height);
        this.terCtx.fillStyle = this.fillStyle;

        if (new Date().getTime() > this.lastScroll + this.scrollDelay) {
            this.lastScroll = new Date().getTime();
            this.points.push(this.points.shift());
        }

        this.terCtx.beginPath();
        for (var i = 0; i <= width; i++) {
            if (i === 0) {
                this.terCtx.moveTo(0, this.points[0]);
            } else if (this.points[i] !== undefined) {
                this.terCtx.lineTo(i, this.points[i]);
            }
        }

        this.terCtx.lineTo(width, this.terrain.height);
        this.terCtx.lineTo(0, this.terrain.height);
        this.terCtx.lineTo(0, this.points[0]);
        this.terCtx.fill();
    }


    // Second canvas used for the stars
    bgCtx.fillStyle = '#05004c';
    bgCtx.fillRect(0, 0, width, height);

    // stars
    function Star(options) {
        this.size = Math.random() * 2;
        this.speed = Math.random() * 0.1;
        this.x = options.x;
        this.y = options.y;
    }

    Star.prototype.reset = function () {
        this.size = Math.random() * 2;
        this.speed = Math.random() * 0.1;
        this.x = width;
        this.y = Math.random() * height;
    }

    Star.prototype.update = function () {
        this.x -= this.speed;
        if (this.x < 0) {
            this.reset();
        } else {
            bgCtx.fillRect(this.x, this.y, this.size, this.size);
        }
    }

    function ShootingStar() {
        this.reset();
    }

    ShootingStar.prototype.reset = function () {
        this.x = Math.random() * width;
        this.y = 0;

        if (isMobile()) {
            this.len = (Math.random() * 20);
            this.speed = (Math.random() * 10) + 5;
        } else {
            this.len = (Math.random() * 30) + 10;
            this.speed = (Math.random() * 10) + 10;
        }
        this.size = (Math.random() * 1) + 0.3;
        // this is used so the shooting stars arent constant
        this.waitTime = new Date().getTime() + (Math.random() * 30) + 50;
        this.active = false;
    }

    ShootingStar.prototype.update = function () {
        if (this.active) {
            this.x -= this.speed;
            this.y += this.speed;
            if (this.x < 0 || this.y >= height) {
                this.reset();
            } else {
                bgCtx.lineWidth = this.size;
                bgCtx.beginPath();
                bgCtx.moveTo(this.x, this.y);
                bgCtx.lineTo(this.x + this.len, this.y - this.len);
                bgCtx.stroke();
            }
        } else {
            if (this.waitTime < new Date().getTime()) {
                this.active = true;
            }
        }
    }

    var entities = [];

    // init the stars
    for (var i = 0; i < height; i++) {
        entities.push(new Star({
            x: Math.random() * width,
            y: Math.random() * height
        }));
    }

    // Add 2 shooting stars that just cycle.
    entities.push(new ShootingStar());
    entities.push(new ShootingStar());
    entities.push(new Terrain({mHeight: (height / 1.16) - 130}));
    entities.push(new Terrain({
        displacement: 120,
        scrollDelay: 50,
        fillStyle: "rgb(17,20,40)",
        mHeight: (height / 1.16) - 60
    }));
    entities.push(new Terrain({displacement: 100, scrollDelay: 20, fillStyle: "rgb(10,10,5)", mHeight: height / 1.16}));

    //animate background
    function animate() {
        bgCtx.fillStyle = '#110E19';
        bgCtx.fillRect(0, 0, width, height);
        bgCtx.fillStyle = '#ffffff';
        bgCtx.strokeStyle = '#ffffff';

        var entLen = entities.length;

        while (entLen--) {
            entities[entLen].update();
        }
        requestAnimationFrame(animate);
    }
    animate();

    //禁止缩放
    //luwenjie hualun
    window.addEventListener('mousewheel', function(event){
        if (event.ctrlKey === true || event.metaKey) {
            event.preventDefault();
        }
    },{ passive: false});

    //firefox
    window.addEventListener('DOMMouseScroll', function(event){
        if (event.ctrlKey === true || event.metaKey) {
            event.preventDefault();
        }
    },{ passive: false});
    //+_
    window.onload = function() {
        document.addEventListener('keydown', function (event) {
            if ((event.ctrlKey === true || event.metaKey === true)
                && (event.which === 61 || event.which === 107
                    || event.which === 173 || event.which === 109
                    || event.which === 187  || event.which === 189))
            {
                event.preventDefault();
            }
        }, false);
    }

    //取消选中并且取消右键操作
    document.body.oncontextmenu =
        function () {
            return false; //取消浏览器默认操作
        };
    document.onkeydown = function () {
        if (window.event && window.event.keyCode == 123) {
            event.keyCode = 0;
            event.returnValue = false;
        }
        if (window.event && window.event.keyCode == 13) {
            window.event.keyCode = 505;
        }

        // if (window.event && window.event.keyCode == 8) {
        //     alert(str+"\n请使用Del键进行字符的删除操作！");
        //     window.event.returnValue = false;
        // }

        // 禁止通过F12打开控制台
        var e = event || window.event || arguments.callee.caller.arguments[0];
        // 屏蔽ctrl+s 保存
        if (e.ctrlKey && e.keyCode == 83) {
            // alert('禁止使用ctrl+s');
            e.preventDefault();
            e.returnValue = false;
            return false;
        }
        // 屏蔽ctrl+p 打印
        if (e.ctrlKey && e.keyCode == 80) {
            // alert('禁止使用ctrl+p');
            e.preventDefault();
            e.returnValue = false;
            return false;
        }
    }
    // 禁止拖拽
    window.ondragstart = function () {
        return false;
    }
    !function () {
        var timelimit = 50;
        var open = false;
        setInterval(function () {
            var starttime = new Date();

            if (new Date() - starttime > timelimit) {
                open = true;
                window.stop();
                document.getElementById("loading").hide();
                document.getElementById("a1").remove();
                document.getElementById("error").show();
                document.getElementById("error").html("\u7cfb\u7edf\u68c0\u6d4b\u975e\u6cd5\u8c03\u8bd5\u002c\u8bf7\u5237\u65b0\u91cd\u8bd5\u0021")
            } else {
                open = false
            }
        }, 500)
    }();
</script>

</body>
</html>
